package homework;

import java.util.Scanner;

public class Manegement {
    public static void main(String[] args) {
        //输入课程数量
        System.out.println("请输入课程数量:");
        Scanner inputCourseNumber = new Scanner(System.in);
        int numberOfCourse = inputCourseNumber.nextInt();
        //根据课程数量,创建课程对象
        Course[] courses = new Course[numberOfCourse];
        //循环输入课程名
        for(int i = 0 ; i <numberOfCourse ; i++){
            courses[i] = new Course();
            System.out.println("请输入课程名称:");
            Scanner inputCourseName = new Scanner(System.in);
            courses[i].setCourseName(inputCourseName.nextLine());
        }
        //输入学生数量
        System.out.println("请输入学生数量:");
        Scanner inputNumber = new Scanner(System.in);
        int numberOfStudent = inputNumber.nextInt();
        //根据学生数量,创建学生对象
        Student[] students = new Student[numberOfStudent];
        for(int i = 0; i<numberOfStudent; i++) {
            students[i] = new Student();
            System.out.println("请输入第" + (i + 1) + "个学生学号:");
            Scanner inputId = new Scanner(System.in);
            students[i].setId(inputId.nextLine());
            System.out.println("请输入第" + (i + 1) + "个学生姓名:");
            Scanner inputName = new Scanner(System.in);
            students[i].setName(inputName.nextLine());
            //输入第i+1个学生选课数量
            System.out.println("请输入第" + (i + 1) + "个学生选的课程数量");
            Scanner inCourseNumber = new Scanner(System.in);
            int numberOfCourses = inCourseNumber.nextInt();
            //该生选课情况
            for(int j = 0; j <numberOfCourses ; j++){
                System.out.println( "请输入该学生所选的课程：" );
                Scanner inputCourseName = new Scanner(System.in);
                courses[j].setCourseName(inputCourseName.nextLine());
            }
        }
        //输出每个学生所选的所有的课程的列表
        for( int i = 0 ; i < numberOfStudent ; i++ ){
            System.out.println( "学生学号：" + students[i].getId());
            System.out.println( "学生姓名：" + students[i].getName());
            for(int j = 0 ; j < courses.length; j++)
            System.out.println("此学生选的课有：" + courses[j].getCourseName());
        }
        //输出每个课程的所有选课的学生的列表
    }
}
